package com.yks.hbo.amazon.service;

import com.alibaba.fastjson.JSONObject;
import com.yks.hbo.amazon.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * @author songxulin
 * @date 2022/3/19
 */
@Component
public class AmazonService {
    @Autowired
    private IPlsAmazonAdAccTokenService iPlsAmazonAdAccTokenService;
    public String advertisingOauth(String jsonParam) {
        ResultVO resultVO = new ResultVO();
        try {
            JSONObject data = JSONObject.parseObject(jsonParam).getJSONObject("data");
            if (data == null) {
                throw new Exception("data不能为空！");
            }
            if (StringUtils.isEmpty(data.getString("region"))) {
                throw new Exception("region不能为空！");
            }
            resultVO = iPlsAmazonAdAccTokenService.advertisingOauth(data.getString("region"));
        }catch (Exception e){
            resultVO.setMsg(e.getMessage());
        }
        return JSONObject.toJSONString(resultVO);
    }
}
